package top.tanglizhi.springboot3.controller.test;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.tanglizhi.springboot3.aop.BucketLimit;
import top.tanglizhi.springboot3.aop.BucketLimitMode;
import top.tanglizhi.springboot3.aop.Limit;
import top.tanglizhi.springboot3.base.R;

@RestController
@RequestMapping("/test/limit")
public class LimitTestController {
    @GetMapping("/one")
    @Limit(key = "one", timeout = 10)
    public R<String> one(String message) {
        return R.ok(message);
    }

    @GetMapping("/two")
    @Limit(key = "two", message = "自定义限流信息")
    public R<String> two(String message) {
        return R.ok(message);
    }

    @GetMapping("/three")
    @BucketLimit(key = "three", timeout = 3 * 60, capacity = 5, message = "哈哈哈", mode = BucketLimitMode.IP)
    public R<String> three(String message) {
        return R.ok(message);
    }

    @GetMapping("/four")
    @BucketLimit(key = "four", capacity = 10, mode = BucketLimitMode.IP)
    public R<String> four(String message) {
        return R.ok(message);
    }
}
